<template>
  <div class="container">
    <el-form ref="checkForm" :rules="checkFormRules" :model="checkForm">
      <el-form-item>
        <el-radio-group v-model="checkForm.chkState">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">拒绝</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item prop="chkRemarks">
        <el-input type="textarea" v-model="checkForm.chkRemarks"></el-input>
      </el-form-item>
      <el-form-item style="text-align: right">
        <el-button type="primary" @click="onSubmit">确认</el-button>
        <el-button @click="$emit('update:questionsCheckVisible', false)"
          >取消</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'

export default {
  name: 'questionsCheck',
  props: {
    questionsCheckVisible: {
      type: Boolean
    }
  },
  data () {
    return {
      checkForm: {
        id: null,
        chkState: 1,
        chkRemarks: ''
      },
      checkFormRules: {
        chkRemarks: [
          { required: true, message: '请输入审核意见', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    onSubmit () {
      this.$refs.checkForm.validate(async (valid) => {
        if (valid) {
          const res = await choiceCheck(this.checkForm)
          if (res.status === 200) {
            this.$message.success('操作成功')
            this.$emit('success')
            this.$emit('update:questionsCheckVisible', false)
          }
        } else {
          this.$message.warning('请输入审核意见')
        }
      })
    }
  }
}
</script>

<style scoped lang='scss'></style>
